import csv
import os

current_path = os.path.dirname(__file__).split("utils")[0]


def read_csv_file(file_name):
    datas = []
    csv_file_path = os.path.join(current_path, 'data', file_name)
    with open(csv_file_path, 'r', encoding="utf-8") as csvfile:
        reader = csv.DictReader(csvfile,quotechar='"')
        for row in reader:
            for key,value in row.items():
                if value == "NA":
                    value = ""
                    row.update({key: value})
                elif "["in value and "]" in value:
                    new_value = value[1:-1]
                    row.update({key: new_value})
                else:
                    continue
            datas.append(row)
    return datas
